package bdu;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the formula used to determine firing power returns the expected results.
 * 
 * @author Bao Huy Ung
 * 
 */
public class TestScavengerFirePower {

  /**
   * Tests the closet range 1 pixel distance.
   */
  @Test
  public void testNear() {
    assertTrue("Near robot generates high fire power", calculatePower(1) > 2.8);
  }

  /**
   * Tests the farthest non-max distance 1 pixel from max.
   */
  @Test
  public void testFar() {
    assertTrue("Far robot generates lower fire power", calculatePower(1199) < 0.3);
  }

  /**
   * Power calculation function based on enemy distance.
   * 
   * @param distance the distance from the enemy.
   * @return The firing power.
   */
  public double calculatePower(double distance) {
    // firing formula based on max distance 1200 and target's distance
    return (3.1 - distance / 1200 * 3);
  }
}
